const users=require("../models/users.models")

const isAuthenticated =function(req,res,next){
    let token=req.get('token');
    users.getIDFromToken(token,(err,user_id)=>{
        if(err || user_id ===null){
            return res.sendError({ msg:'没有登录,请先登录' },403);
        }
        next()
    });
}

module.exports = {
    isAuthenticated,
}
